#ifndef _DB_LOCK_H_92ULSDJFQ23RLKAJFO_
#define _DB_LOCK_H_92ULSDJFQ23RLKAJFO_


#include "filelock.h"

typedef struct dblock_t
{
	char* fname;
	file_lock_t* locker;
	void* cursor;
}dblock_t;

#define EDBL_OK  0
#define EDBL_LOCK 1
#define EDBL_FILE 2
#define EDBL_FIND 3
#define EDBL_STORE 4
#define EDBL_PARAM 5

dblock_t* dblock_open(const char* fname);
void dblock_close(dblock_t*me);

int dblock_fetch(dblock_t*me, void* key, int keylen, void** pdata);
int dblock_fetch_ex(dblock_t*me, void* key, int keylen, void** pdata, int* pdatalen);
int dblock_replace(dblock_t*db, void* key, int keylen, void* data, int datalen) ;
int dblock_insert(dblock_t*db, void* key, int keylen, void* data, int datalen) ;
int dblock_delete(dblock_t*db, void* key, int keylen);

int dblock_count(dblock_t*db,int * pcount);

int dblock_opencursor(dblock_t*db);
int dblock_firstkey(dblock_t*db, void** pkey, int* plen,void ** pdata,int *pdatalen);
int dblock_nextkey(dblock_t*db, void** pkey, int* plen,void ** pdata,int *pdatalen);
int dblock_closecursor(dblock_t*db);


#endif //_DB_LOCK_H_92ULSDJFQ23RLKAJFO_
